package space.goldchen.mapstruct;

import ch.qos.logback.classic.Logger;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import space.goldchen.mapstruct.dto.PersonDto;
import space.goldchen.mapstruct.dto.PigDto;
import space.goldchen.mapstruct.entity.Person;
import space.goldchen.mapstruct.entity.Pig;
import space.goldchen.mapstruct.mapper.PersonMapper;
import space.goldchen.mapstruct.mapper.PigDtoMapper;

@SpringBootTest
@Slf4j
class MapStructApplicationTests {
    @Resource
    private PigDtoMapper pigDtoMapper;
    @Resource
    private PersonMapper personMapper;

    @DisplayName("测试Pig转PigDto")
    @Test
    void testPigDtoMapper() {
        Pig pig = new Pig();
        pig.setId(1L);
        pig.setName("pig");
        pig.setAge(2);
        pig.setPrice(100.0);
        PigDto pigDto = pigDtoMapper.toDto(pig);
        log.info("pigDto:{}", pigDto);
    }


    @DisplayName("测试Person转PersonDto")
    @Test
    void testPersonToPersonDto () {
        Person person = new Person();
        person.setId(2L);
        person.setName("我是personName");
        PersonDto personDto = personMapper.toDto(person);
        log.info("personDto:{}", personDto);
    }

}
